import request from '@/utils/request'
import { tokenName } from '@/config'

export async function login(data) {
  // if (loginRSA) {
  //   data = await encryptedData(data)
  // }
  return request({
    url: '/user/login',
    method: 'post',
    data,
  })
}

export function getUserInfo(accessToken) {
  return request({
    url: '/user/getInfo',
    method: 'get',
    data: {
      [tokenName]: accessToken,
    },
  })
}

export function logout(accessToken) {
  return request({
    url: '/user/logout',
    method: 'get',
    data: {
      [tokenName]: accessToken,
    },
  })
}

export function register(data) {
  return request({
    url: '/user/register',
    method: 'post',
    data,
  })
}

export function findUserByName(data) {
  return request({
    url: '/user/findUserByName?userName=' + data,
    method: 'get',
  })
}
